#include "iobot.h"

void iobot_put_number(iobot_t *bot, unsigned int num)
{
	if(num < 10)
	{
		iobot_put_char(bot, 0x30);
	}
	if(num == 0)
	{
		iobot_put_char(bot, 0x30);
	}
	
	unsigned int temp = 0;
	unsigned int remainder = 0;
	char text[11];//longest possible integer is 10 digits long + the null terminator
	unsigned int index = 9;
	unsigned int i = 0;
	text[10] = 0x00;
	while((num != 0) & (index < 11))
	{
		temp = num / 10;
		remainder = num % 10;
		
		text[index] = remainder + 48;
		index--;

		num = temp;
	}
	index++;
	//shift the letters to the beginning of the array
	for(i = index; i < 11; i++)
	{
		text[i - index] = text[i];
		text[i] = 0x00;
	}
	iobot_put_string(bot,text);
} 
